clear all 



*************************************************************** 
*** verifying against "hdm" package in R (Spindler et al.)	***
*** hdmlambda option ensures same lambda is used			***
***************************************************************


insheet using "spam.data", clear delim(" ")

rlassologit v58 v1-v57  , hdmlambda
mat S = e(beta)'
mat G = ( 0 \ 0 \ 0.0818948712695488 \ 0 \ 0.379429361719609 \ 0.409109085956748 \ 1.9003258692222 \ 0.431150805857511 \ 0.315744217129519 \ 0.0049820928287534 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0.447978507142549 \ 0.443934277021981 \ 0.192865405720127 \ 0.0625091762029476 \ 0.248557045294218 \ 0.245131827365983 \ 0.109668219678555 \ 1.43731652314774 \ 0.440704475266581 \ -0.480122280718989 \ -0.223595359843765 \ -0.0875263945521702 \ 0 \ 0 \ 0 \ 0 \ 0 \ -0.14385510842836 \ 0 \ 0 \ 0 \ -0.134425982189653 \ 0 \ -0.0324979517942505 \ 0 \ 0 \ -0.299792597221532 \ -0.0178914234516845 \ -0.0405270661669486 \ -0.215984667465846 \ -0.256364202865828 \ 0 \ -0.00501707194224279 \ -0.113031184465464 \ 0 \ 0 \ 0.418975832790503 \ 3.25756538129954 \ 0 \ 0 \ 0.000923864682472632 \ 0.000432834090656421 \ -1.66933973402153 )
di mreldif(S,G)
di e(lambda)
assert mreldif(S,G)<0.01

rlassologit v58 v1-v57 ,nocons hdmlambda
mat S = e(beta)'
mat G = ( 0 \ -0.0864040297967744 \ 0 \ 0 \ 0.14203538121037 \ 0.0696029895895297 \ 1.5124020295351 \ 0.241304873304514 \ 0.089231885869934 \ 0 \ 0 \ -0.262648802099565 \ 0 \ 0 \ 0.0221381492679238 \ 0.273749502669813 \ 0.32684735941686 \ 0.0176157322393083 \ 0 \ 0.229847624122447 \ 0.0820838755349145 \ 0.0349736719705019 \ 1.27572289568391 \ 0.318345425501668 \ -0.75361780468791 \ -0.371276657650674 \ -0.184069780173229 \ 0 \ 0 \ 0 \ 0 \ 0 \ -0.451510644154917 \ 0 \ -0.0468459332646387 \ 0 \ -0.377889219838404 \ 0 \ -0.136072245922347 \ 0 \ 0 \ -0.494978796805398 \ -0.191973864938743 \ -0.274310171697392 \ -0.512607089354212 \ -0.622744742178529 \ -0.227169791356443 \ -0.289531930392509 \ -0.364271673492403 \ -0.979682797504907 \ -0.325414901150868 \ 0.160823428575976 \ 2.80067037980844 \ 0 \ 0 \ 0.00070917591496024 \ 9.75715276693764e-05 )
di mreldif(S,G)
di e(lambda) 
assert mreldif(S,G)<0.01

rlassologit v58 v1-v57 , postl hdmlambda
mat S = e(beta_post)'
mat G = ( 0 \ 0 \ 0.0911749035363913 \ 0 \ 0.600348234636252 \ 0.848587006358465 \ 2.4474282743846 \ 0.640213550033936 \ 0.72606218429801 \ 0.108244564804095 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0.999045440309051 \ 0.990826392555297 \ 0.126234229254353 \ 0.0760883260691006 \ 1.23427664731182 \ 0.163969519238026 \ 0.340943971216137 \ 2.19787084433997 \ 0.517482714211636 \ -1.95041244716883 \ -0.865071034109125 \ -12.3112008896115 \ 0 \ 0 \ 0 \ 0 \ 0 \ -0.803106762101585 \ 0 \ 0 \ 0 \ 0.0241819026296822 \ 0 \ -0.826519776504054 \ 0 \ 0 \ -2.79996722215776 \ -1.28167204241549 \ -1.71051269617404 \ -0.730702205605326 \ -1.57125641472336 \ 0 \ -4.53973467862469 \ -1.21039378912067 \ 0 \ 0 \ 0.392453914192812 \ 5.70993167564932 \ 0 \ 0 \ 0.0119032569623226 \ 0.000562741641538757 \ -1.6805612492106 )
di mreldif(S,G)
di e(lambda) 
assert mreldif(S,G)<0.01

rlassologit v58 v1-v57 ,postl nocons hdmlambda
mat S = e(beta_post)'
mat G = ( 0 \ -0.243870343170744 \ 0 \ 0 \ 0.323758365384805 \ 0.365895137099397 \ 2.14831819350489 \ 0.52796289907392 \ 0.463041759179273 \ 0 \ 0 \ -0.40515745464642 \ 0 \ 0 \ 1.26334873669496 \ 0.794860192566074 \ 0.848935809630871 \ -0.0498307343945656 \ 0 \ 1.33427727401593 \ 0.0455995142062725 \ 0.327362342472093 \ 1.975974600918 \ 0.382498934793842 \ -2.23935890965794 \ -0.974877197129703 \ -9.3264468573156 \ 0 \ 0 \ 0 \ 0 \ 0 \ -1.08698081175868 \ 0 \ -2.15476075561477 \ 0 \ -0.225337578437582 \ 0 \ -0.956767386369015 \ 0 \ 0 \ -3.02443544634889 \ -1.90127824511308 \ -2.30281566974477 \ -1.10179581057555 \ -2.17680028017689 \ -2.63960623014879 \ -4.34961066961778 \ -1.61635289440844 \ -1.04825259598903 \ -1.67651030427761 \ 0.222992581890547 \ 5.18632237505927 \ 0 \ 0 \ 0.00780983251377047 \ 0.000304166775336087 )
di mreldif(S,G)
di e(lambda)
assert mreldif(S,G)<0.01
